package org.aurelius.testngexecutionlogger;

import java.util.ArrayList;
import java.util.List;
import org.apache.log4j.Logger;

/**
 * Hello world!
 *
 */
public class App {

    private static Logger logger = Logger.getLogger(App.class);

    public static void main(String[] args) {
        
        final Repository repository = new Repository(55000);
        repository.fillRepository();

        List list = new ArrayList();
        for (int i = 0; i < 950; i++) {

            Thread thread = new Thread() {

                @Override
                public void run() {
                    List<Integer> data = repository.getData();

                    for (Integer integer : data) {
                        int kk = integer++;
                        integer++;
                        integer--;

                    }
                }
            };
            list.add(thread);

            if (i % 10 == 0) {
                Thread thread2 = new Thread() {

                    @Override
                    public void run() {
                        repository.getData().add(30000, 2);
                        repository.getData().add(30002, 2);

                    }
                };
                list.add(thread2);
            }
            if (i % 10 == 0) {
                Thread thread2 = new Thread() {

                    @Override
                    public void run() {
                        repository.getData().remove(3000);
                        repository.getData().remove(43000);
                    }
                };
                list.add(thread2);
            }
        }


        for (Object object : list) {

            Thread th = (Thread) object;

            th.start();
        }

        System.out.println(repository.getData().size());
    }
}
